<?php

namespace iBrand\Shop\Core;

use iBrand\Scheduling\Schedule\Scheduling;
use iBrand\Component\Point\Model\Point;

class Schedule extends Scheduling
{

    public function schedule()
    {
        $this->schedule->call(function () {
            $invalidPoint = Point::where('action', 'register_gift')->where('status', 0)->get();
            if ($invalidPoint->count()) {
                foreach ($invalidPoint as $item) {
                    $item->status = 1;
                    $item->save();

                    event('point.change', [$item->user_id]);
                }
            }
        })->daily();
    }

}